package com.zhangjg.database;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class TableDao<Bean> extends SelectDao<Bean> {

    @SuppressWarnings("unchecked")
    @Override
    protected Bean loadBean(ResultSet rs) {
        try {
            return (Bean)rs.getObject(1);
        } catch (SQLException e) {
            return null;
        }
    }
    
    public long count(String sql,List<Object> params) {
        List<Bean> list = select(sql, params);
        if (list != null && list.size() > 0)
            return Long.parseLong(list.get(0).toString());
        return 0;
    }


}
